package shin.test.web.logic;

import java.io.IOException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

@SuppressWarnings("serial")
public class BlogDemoServlet extends HttpServlet {
	public void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		// アプリケーションコンテキストの取得
		ApplicationContext contxt = new ClassPathXmlApplicationContext(
				"applicationContext.xml");

		// Beanの取得
		Target target = (Target) contxt.getBean("target");

		System.out.println(target.getMessage());
		resp.setContentType("text/plain");
		resp.getWriter().println(target.getMessage());
	}
}
